<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input type="text" placeholder="enter the name you search" v-model="userName"/>&nbsp;
      <button @click="handler">Search</button>
    </div>
  </section>
</template>

<script>
export default {
  name: "",
  data(){
    return {
      //收集表单数据：ref|v-model 
      userName:''
    }
  },
  methods: {
     //按钮的回调函数
     handler(){
       //Header组件需要把收集到的用户信息传递给兄弟组件Footer
       //获取用户名
       const {userName} = this;
       //判断用户名得有才能给兄弟
       if(userName.trim()=='') return;
       //$emit给兄弟传递数据
       this.$bus.$emit('send',userName);
       //清空文本内容
       this.userName = '';
     }
  },
};
</script>

<style scoped>
</style>
